package cn.zane.principle.richterSubstitutionPrinciple.oldCode;

import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Author: zane
 * @Date: 2024/12/15
 * @Description:
 */
@Slf4j
public class CreditCard extends CashCard {

    @Override
    public String withdrawal(String orderId, BigDecimal amount) {
        // 校验
        if (amount.compareTo(BigDecimal.valueOf(1000)) >= 0) {
            log.info("贷款金额校验(限额1000元)，单号:{} 金额:{}", orderId, amount);
            return "0001";
        }
        log.info("生成贷款单，单号:{} 金额:{}", orderId, amount);
        log.info("贷款成功，单号:{} 金额:{}", orderId, amount);
        return "0000";
    }

    @Override
    public String recharge(String orderId, BigDecimal amount) {
        log.info("生成还款单，单号:{} 金额:{}", orderId, amount);
        log.info("还款成功，单号:{} 金额:{}", orderId, amount);
        return "0000";
    }

    @Override
    public List<String> tradeFlow() {
        return super.tradeFlow();
    }

    public static void main(String[] args) {
        CreditCard creditCard = new CreditCard();
        creditCard.withdrawal("0001", BigDecimal.valueOf(1000));
        creditCard.recharge("0002", BigDecimal.valueOf(1000));
        creditCard.tradeFlow();
    }
}
